﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Business.Base.DB.Query
{
    public class ExperimentQuery : BaseQuery
    {
        String code = null;                                    //试验编号
        DateTime createStartTime = DateTime.Parse("1990-01-01");// new DateTime.(1990,1,1);     //试验开始时间
        DateTime createEndTime = DateTime.Parse("2050-01-01"); //new DateTime(2050, 1, 1);   //试验开始时间
        String pumpModel = null;         //产品型号
        String pumpCode = null;          //产品编号
        String experimentOwner = null;   //试验人员
        String manufacturer = null;      //生产商
        String customer = null;
        String pumpName = null;
       



        int[] pumpType = null;          // 泵类型 1. 普通离心泵  2. 潜水电泵  3. 潜污泵  4. 螺杆泵    
        int[] experimentType = null;    // 试验类型 1.性能测试 2.气蚀试验 3.空载试验 4.温升试验 5.负载试验 6.堵转试验 

        public string Code { get => code; set => code = value; }
        public DateTime CreateStartTime { get => createStartTime; set => createStartTime = value; }
        public DateTime CreateEndTime { get => createEndTime; set => createEndTime = value; }
        public string PumpModel { get => pumpModel; set => pumpModel = value; }
        public string PumpCode { get => pumpCode; set => pumpCode = value; }
        public string ExperimentOwner { get => experimentOwner; set => experimentOwner = value; }
        public string Manufacturer { get => manufacturer; set => manufacturer = value; }
        public int[] PumpType { get => pumpType; set => pumpType = value; }
        public int[] ExperimentType { get => experimentType; set => experimentType = value; }
        public string Customer { get => customer; set => customer = value; }
        public string PumpName { get => pumpName; set => pumpName = value; }

    

       


        public override string ToSQLConditionWithOutSort()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(" where ");
            sb.Append(" (createTime > '" + this.CreateStartTime.ToString() + "' and createTime <'" + this.CreateEndTime.ToString() + "')");

            if (this.Code != null && this.Code.Trim().Length != 0)
            {
                sb.Append(" and  (experimentCode like '%" + this.Code + "%') ");
            }
            if (this.PumpName != null && this.PumpName.Length != 0)
            {
                sb.Append(" and  (pumpName like '%" + this.PumpName + "%') ");
            }
            if (this.Customer != null && this.Customer.Length != 0)
            {
                sb.Append(" and  (customer like '%" + this.Customer + "%') ");
            }
            if (this.ExperimentOwner != null && this.ExperimentOwner.Length != 0)
            {
                sb.Append(" and  (experimentOwner like '%" + this.ExperimentOwner + "%') ");
            }
            if (this.Manufacturer != null && this.Manufacturer.Trim().Length != 0)
            {
                sb.Append(" and  (manufacturer like '%" + this.Manufacturer + "%') ");
            }
            if (this.PumpCode != null && this.PumpCode.Trim().Length != 0)
            {
                sb.Append(" and  (pumpCode like '%" + this.PumpCode + "%') ");
            }
            if (this.PumpModel != null && this.PumpModel.Trim().Length != 0)
            {
                sb.Append(" and  (pumpModel like '%" + this.PumpModel + "%') ");
            }
            if (this.PumpType != null && this.PumpType.Length != 0)
            {
                sb.Append(" and  (pumpType in (");
                foreach (int v in this.PumpType)
                {
                    sb.Append(v.ToString() + ",");
                }
                sb.Append("0)) ");
            }
            if (this.ExperimentType != null && this.ExperimentType.Length != 0)
            {
                sb.Append(" and  (experimentType in (");
                foreach (int v in this.ExperimentType)
                {
                    sb.Append(v.ToString() + ",");
                }
                sb.Append("0)) ");
            }


            return sb.ToString();

        }
    }
}
